
var _oErrors =
{
sNoFileSpecified:		LOCID_IMPORT_NOFILESPECIFIED,
sInvalidFileName:		LOCID_IMPORT_INVALIDFILENAME,
sInvalidFileExtension:	LOCID_IMPORT_INVALIDFILEEXT,
sInvalidFilePath:		LOCID_IMPORT_INVALIDFILEPATH,
sNavigateAwayWarning:	LOCID_IMPORT_NAVIGATEAWAY
};


function uploadFile()
{
UploadForm.btnUploadFile.disabled=true;

var sFileName = UploadForm.userFile.value;


if (sFileName == "")
{
alert(_oErrors.sNoFileSpecified);
UploadForm.btnUploadFile.disabled=false;
return false;
}


var regex = "[?\"/*<>|]";

if (sFileName.length > 100 || sFileName.search(regex) != -1)
{
alert(_oErrors.sInvalidFileName);
UploadForm.btnUploadFile.disabled=false;
return false;
}


sFileName = sFileName.slice(sFileName.lastIndexOf("\\") + 1);
var sExtension = sFileName.slice(sFileName.lastIndexOf(".") + 1).toLowerCase();

if (sExtension != "xml" && sExtension != "zip")
{
alert(_oErrors.sInvalidFileExtension);
UploadForm.btnUploadFile.disabled=false;
return false;
}




document.body.onbeforeunload = onNavigateAway;



UploadForm.fileName.value = UploadForm.userFile.value;


UploadForm.action.value = "upload-parse";
UploadForm.target = "GridFrame";



try
{
UploadForm.submit();
}
catch (e)
{
alert(_oErrors.sInvalidFilePath);
return false;
}
}


function onNavigateAway()
{
event.returnValue = _oErrors.sNavigateAwayWarning;
}

function showStatusDialog()
{
openStdDlg(prependOrgName("/tools/systemcustomization/importcustomizations/importStatus.aspx"), this.parent, 400, 400, false, false);
}
